<?php


abstract class BaseDemande extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $demande_id;


	
	protected $date;


	
	protected $nom;


	
	protected $prenom;


	
	protected $statut_id;


	
	protected $statut_autre;


	
	protected $etablissement_id;


	
	protected $structure_autre;


	
	protected $intitule_etude;


	
	protected $type_donnees_id;


	
	protected $type_donnees_autre;


	
	protected $periode_debut;


	
	protected $periode_fin;


	
	protected $format_donnees_id;


	
	protected $is_besoin_assistance;


	
	protected $type_motivation_id;


	
	protected $commentaire;

	
	protected $aTypeStatut;

	
	protected $aEtablissement;

	
	protected $aTypeDonnees;

	
	protected $aTypeFormatDonnees;

	
	protected $aTypeMotivation;

	
	protected $collDemandeEvaluations;

	
	protected $lastDemandeEvaluationCriteria = null;

	
	protected $collDemandeSupervisions;

	
	protected $lastDemandeSupervisionCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getDemandeId()
	{

		return $this->demande_id;
	}

	
	public function getDate($format = 'Y-m-d H:i:s')
	{

		if ($this->date === null || $this->date === '') {
			return null;
		} elseif (!is_int($this->date)) {
						$ts = strtotime($this->date);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [date] as date/time value: " . var_export($this->date, true));
			}
		} else {
			$ts = $this->date;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getNom()
	{

		return $this->nom;
	}

	
	public function getPrenom()
	{

		return $this->prenom;
	}

	
	public function getStatutId()
	{

		return $this->statut_id;
	}

	
	public function getStatutAutre()
	{

		return $this->statut_autre;
	}

	
	public function getEtablissementId()
	{

		return $this->etablissement_id;
	}

	
	public function getStructureAutre()
	{

		return $this->structure_autre;
	}

	
	public function getIntituleEtude()
	{

		return $this->intitule_etude;
	}

	
	public function getTypeDonneesId()
	{

		return $this->type_donnees_id;
	}

	
	public function getTypeDonneesAutre()
	{

		return $this->type_donnees_autre;
	}

	
	public function getPeriodeDebut($format = 'Y-m-d')
	{

		if ($this->periode_debut === null || $this->periode_debut === '') {
			return null;
		} elseif (!is_int($this->periode_debut)) {
						$ts = strtotime($this->periode_debut);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [periode_debut] as date/time value: " . var_export($this->periode_debut, true));
			}
		} else {
			$ts = $this->periode_debut;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getPeriodeFin($format = 'Y-m-d')
	{

		if ($this->periode_fin === null || $this->periode_fin === '') {
			return null;
		} elseif (!is_int($this->periode_fin)) {
						$ts = strtotime($this->periode_fin);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [periode_fin] as date/time value: " . var_export($this->periode_fin, true));
			}
		} else {
			$ts = $this->periode_fin;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getFormatDonneesId()
	{

		return $this->format_donnees_id;
	}

	
	public function getIsBesoinAssistance()
	{

		return $this->is_besoin_assistance;
	}

	
	public function getTypeMotivationId()
	{

		return $this->type_motivation_id;
	}

	
	public function getCommentaire()
	{

		return $this->commentaire;
	}

	
	public function setDemandeId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->demande_id !== $v) {
			$this->demande_id = $v;
			$this->modifiedColumns[] = DemandePeer::DEMANDE_ID;
		}

	} 
	
	public function setDate($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [date] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->date !== $ts) {
			$this->date = $ts;
			$this->modifiedColumns[] = DemandePeer::DATE;
		}

	} 
	
	public function setNom($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nom !== $v) {
			$this->nom = $v;
			$this->modifiedColumns[] = DemandePeer::NOM;
		}

	} 
	
	public function setPrenom($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->prenom !== $v) {
			$this->prenom = $v;
			$this->modifiedColumns[] = DemandePeer::PRENOM;
		}

	} 
	
	public function setStatutId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->statut_id !== $v) {
			$this->statut_id = $v;
			$this->modifiedColumns[] = DemandePeer::STATUT_ID;
		}

		if ($this->aTypeStatut !== null && $this->aTypeStatut->getIdstatut() !== $v) {
			$this->aTypeStatut = null;
		}

	} 
	
	public function setStatutAutre($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->statut_autre !== $v) {
			$this->statut_autre = $v;
			$this->modifiedColumns[] = DemandePeer::STATUT_AUTRE;
		}

	} 
	
	public function setEtablissementId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->etablissement_id !== $v) {
			$this->etablissement_id = $v;
			$this->modifiedColumns[] = DemandePeer::ETABLISSEMENT_ID;
		}

		if ($this->aEtablissement !== null && $this->aEtablissement->getIdetablissement() !== $v) {
			$this->aEtablissement = null;
		}

	} 
	
	public function setStructureAutre($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->structure_autre !== $v) {
			$this->structure_autre = $v;
			$this->modifiedColumns[] = DemandePeer::STRUCTURE_AUTRE;
		}

	} 
	
	public function setIntituleEtude($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->intitule_etude !== $v) {
			$this->intitule_etude = $v;
			$this->modifiedColumns[] = DemandePeer::INTITULE_ETUDE;
		}

	} 
	
	public function setTypeDonneesId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->type_donnees_id !== $v) {
			$this->type_donnees_id = $v;
			$this->modifiedColumns[] = DemandePeer::TYPE_DONNEES_ID;
		}

		if ($this->aTypeDonnees !== null && $this->aTypeDonnees->getIdtypeDonnee() !== $v) {
			$this->aTypeDonnees = null;
		}

	} 
	
	public function setTypeDonneesAutre($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->type_donnees_autre !== $v) {
			$this->type_donnees_autre = $v;
			$this->modifiedColumns[] = DemandePeer::TYPE_DONNEES_AUTRE;
		}

	} 
	
	public function setPeriodeDebut($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [periode_debut] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->periode_debut !== $ts) {
			$this->periode_debut = $ts;
			$this->modifiedColumns[] = DemandePeer::PERIODE_DEBUT;
		}

	} 
	
	public function setPeriodeFin($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [periode_fin] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->periode_fin !== $ts) {
			$this->periode_fin = $ts;
			$this->modifiedColumns[] = DemandePeer::PERIODE_FIN;
		}

	} 
	
	public function setFormatDonneesId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->format_donnees_id !== $v) {
			$this->format_donnees_id = $v;
			$this->modifiedColumns[] = DemandePeer::FORMAT_DONNEES_ID;
		}

		if ($this->aTypeFormatDonnees !== null && $this->aTypeFormatDonnees->getIdformatDonnees() !== $v) {
			$this->aTypeFormatDonnees = null;
		}

	} 
	
	public function setIsBesoinAssistance($v)
	{

		if ($this->is_besoin_assistance !== $v) {
			$this->is_besoin_assistance = $v;
			$this->modifiedColumns[] = DemandePeer::IS_BESOIN_ASSISTANCE;
		}

	} 
	
	public function setTypeMotivationId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->type_motivation_id !== $v) {
			$this->type_motivation_id = $v;
			$this->modifiedColumns[] = DemandePeer::TYPE_MOTIVATION_ID;
		}

		if ($this->aTypeMotivation !== null && $this->aTypeMotivation->getIdtypeMotivation() !== $v) {
			$this->aTypeMotivation = null;
		}

	} 
	
	public function setCommentaire($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->commentaire !== $v) {
			$this->commentaire = $v;
			$this->modifiedColumns[] = DemandePeer::COMMENTAIRE;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->demande_id = $rs->getInt($startcol + 0);

			$this->date = $rs->getTimestamp($startcol + 1, null);

			$this->nom = $rs->getString($startcol + 2);

			$this->prenom = $rs->getString($startcol + 3);

			$this->statut_id = $rs->getInt($startcol + 4);

			$this->statut_autre = $rs->getString($startcol + 5);

			$this->etablissement_id = $rs->getInt($startcol + 6);

			$this->structure_autre = $rs->getString($startcol + 7);

			$this->intitule_etude = $rs->getString($startcol + 8);

			$this->type_donnees_id = $rs->getInt($startcol + 9);

			$this->type_donnees_autre = $rs->getString($startcol + 10);

			$this->periode_debut = $rs->getDate($startcol + 11, null);

			$this->periode_fin = $rs->getDate($startcol + 12, null);

			$this->format_donnees_id = $rs->getInt($startcol + 13);

			$this->is_besoin_assistance = $rs->getBoolean($startcol + 14);

			$this->type_motivation_id = $rs->getInt($startcol + 15);

			$this->commentaire = $rs->getString($startcol + 16);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 17; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Demande object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DemandePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			DemandePeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DemandePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aTypeStatut !== null) {
				if ($this->aTypeStatut->isModified()) {
					$affectedRows += $this->aTypeStatut->save($con);
				}
				$this->setTypeStatut($this->aTypeStatut);
			}

			if ($this->aEtablissement !== null) {
				if ($this->aEtablissement->isModified()) {
					$affectedRows += $this->aEtablissement->save($con);
				}
				$this->setEtablissement($this->aEtablissement);
			}

			if ($this->aTypeDonnees !== null) {
				if ($this->aTypeDonnees->isModified()) {
					$affectedRows += $this->aTypeDonnees->save($con);
				}
				$this->setTypeDonnees($this->aTypeDonnees);
			}

			if ($this->aTypeFormatDonnees !== null) {
				if ($this->aTypeFormatDonnees->isModified()) {
					$affectedRows += $this->aTypeFormatDonnees->save($con);
				}
				$this->setTypeFormatDonnees($this->aTypeFormatDonnees);
			}

			if ($this->aTypeMotivation !== null) {
				if ($this->aTypeMotivation->isModified()) {
					$affectedRows += $this->aTypeMotivation->save($con);
				}
				$this->setTypeMotivation($this->aTypeMotivation);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = DemandePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setDemandeId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += DemandePeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collDemandeEvaluations !== null) {
				foreach($this->collDemandeEvaluations as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collDemandeSupervisions !== null) {
				foreach($this->collDemandeSupervisions as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aTypeStatut !== null) {
				if (!$this->aTypeStatut->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTypeStatut->getValidationFailures());
				}
			}

			if ($this->aEtablissement !== null) {
				if (!$this->aEtablissement->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aEtablissement->getValidationFailures());
				}
			}

			if ($this->aTypeDonnees !== null) {
				if (!$this->aTypeDonnees->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTypeDonnees->getValidationFailures());
				}
			}

			if ($this->aTypeFormatDonnees !== null) {
				if (!$this->aTypeFormatDonnees->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTypeFormatDonnees->getValidationFailures());
				}
			}

			if ($this->aTypeMotivation !== null) {
				if (!$this->aTypeMotivation->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTypeMotivation->getValidationFailures());
				}
			}


			if (($retval = DemandePeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collDemandeEvaluations !== null) {
					foreach($this->collDemandeEvaluations as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collDemandeSupervisions !== null) {
					foreach($this->collDemandeSupervisions as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DemandePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getDemandeId();
				break;
			case 1:
				return $this->getDate();
				break;
			case 2:
				return $this->getNom();
				break;
			case 3:
				return $this->getPrenom();
				break;
			case 4:
				return $this->getStatutId();
				break;
			case 5:
				return $this->getStatutAutre();
				break;
			case 6:
				return $this->getEtablissementId();
				break;
			case 7:
				return $this->getStructureAutre();
				break;
			case 8:
				return $this->getIntituleEtude();
				break;
			case 9:
				return $this->getTypeDonneesId();
				break;
			case 10:
				return $this->getTypeDonneesAutre();
				break;
			case 11:
				return $this->getPeriodeDebut();
				break;
			case 12:
				return $this->getPeriodeFin();
				break;
			case 13:
				return $this->getFormatDonneesId();
				break;
			case 14:
				return $this->getIsBesoinAssistance();
				break;
			case 15:
				return $this->getTypeMotivationId();
				break;
			case 16:
				return $this->getCommentaire();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DemandePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getDemandeId(),
			$keys[1] => $this->getDate(),
			$keys[2] => $this->getNom(),
			$keys[3] => $this->getPrenom(),
			$keys[4] => $this->getStatutId(),
			$keys[5] => $this->getStatutAutre(),
			$keys[6] => $this->getEtablissementId(),
			$keys[7] => $this->getStructureAutre(),
			$keys[8] => $this->getIntituleEtude(),
			$keys[9] => $this->getTypeDonneesId(),
			$keys[10] => $this->getTypeDonneesAutre(),
			$keys[11] => $this->getPeriodeDebut(),
			$keys[12] => $this->getPeriodeFin(),
			$keys[13] => $this->getFormatDonneesId(),
			$keys[14] => $this->getIsBesoinAssistance(),
			$keys[15] => $this->getTypeMotivationId(),
			$keys[16] => $this->getCommentaire(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DemandePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setDemandeId($value);
				break;
			case 1:
				$this->setDate($value);
				break;
			case 2:
				$this->setNom($value);
				break;
			case 3:
				$this->setPrenom($value);
				break;
			case 4:
				$this->setStatutId($value);
				break;
			case 5:
				$this->setStatutAutre($value);
				break;
			case 6:
				$this->setEtablissementId($value);
				break;
			case 7:
				$this->setStructureAutre($value);
				break;
			case 8:
				$this->setIntituleEtude($value);
				break;
			case 9:
				$this->setTypeDonneesId($value);
				break;
			case 10:
				$this->setTypeDonneesAutre($value);
				break;
			case 11:
				$this->setPeriodeDebut($value);
				break;
			case 12:
				$this->setPeriodeFin($value);
				break;
			case 13:
				$this->setFormatDonneesId($value);
				break;
			case 14:
				$this->setIsBesoinAssistance($value);
				break;
			case 15:
				$this->setTypeMotivationId($value);
				break;
			case 16:
				$this->setCommentaire($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DemandePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setDemandeId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setDate($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setNom($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setPrenom($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setStatutId($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setStatutAutre($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setEtablissementId($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setStructureAutre($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setIntituleEtude($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setTypeDonneesId($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setTypeDonneesAutre($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setPeriodeDebut($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setPeriodeFin($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setFormatDonneesId($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setIsBesoinAssistance($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setTypeMotivationId($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setCommentaire($arr[$keys[16]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(DemandePeer::DATABASE_NAME);

		if ($this->isColumnModified(DemandePeer::DEMANDE_ID)) $criteria->add(DemandePeer::DEMANDE_ID, $this->demande_id);
		if ($this->isColumnModified(DemandePeer::DATE)) $criteria->add(DemandePeer::DATE, $this->date);
		if ($this->isColumnModified(DemandePeer::NOM)) $criteria->add(DemandePeer::NOM, $this->nom);
		if ($this->isColumnModified(DemandePeer::PRENOM)) $criteria->add(DemandePeer::PRENOM, $this->prenom);
		if ($this->isColumnModified(DemandePeer::STATUT_ID)) $criteria->add(DemandePeer::STATUT_ID, $this->statut_id);
		if ($this->isColumnModified(DemandePeer::STATUT_AUTRE)) $criteria->add(DemandePeer::STATUT_AUTRE, $this->statut_autre);
		if ($this->isColumnModified(DemandePeer::ETABLISSEMENT_ID)) $criteria->add(DemandePeer::ETABLISSEMENT_ID, $this->etablissement_id);
		if ($this->isColumnModified(DemandePeer::STRUCTURE_AUTRE)) $criteria->add(DemandePeer::STRUCTURE_AUTRE, $this->structure_autre);
		if ($this->isColumnModified(DemandePeer::INTITULE_ETUDE)) $criteria->add(DemandePeer::INTITULE_ETUDE, $this->intitule_etude);
		if ($this->isColumnModified(DemandePeer::TYPE_DONNEES_ID)) $criteria->add(DemandePeer::TYPE_DONNEES_ID, $this->type_donnees_id);
		if ($this->isColumnModified(DemandePeer::TYPE_DONNEES_AUTRE)) $criteria->add(DemandePeer::TYPE_DONNEES_AUTRE, $this->type_donnees_autre);
		if ($this->isColumnModified(DemandePeer::PERIODE_DEBUT)) $criteria->add(DemandePeer::PERIODE_DEBUT, $this->periode_debut);
		if ($this->isColumnModified(DemandePeer::PERIODE_FIN)) $criteria->add(DemandePeer::PERIODE_FIN, $this->periode_fin);
		if ($this->isColumnModified(DemandePeer::FORMAT_DONNEES_ID)) $criteria->add(DemandePeer::FORMAT_DONNEES_ID, $this->format_donnees_id);
		if ($this->isColumnModified(DemandePeer::IS_BESOIN_ASSISTANCE)) $criteria->add(DemandePeer::IS_BESOIN_ASSISTANCE, $this->is_besoin_assistance);
		if ($this->isColumnModified(DemandePeer::TYPE_MOTIVATION_ID)) $criteria->add(DemandePeer::TYPE_MOTIVATION_ID, $this->type_motivation_id);
		if ($this->isColumnModified(DemandePeer::COMMENTAIRE)) $criteria->add(DemandePeer::COMMENTAIRE, $this->commentaire);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(DemandePeer::DATABASE_NAME);

		$criteria->add(DemandePeer::DEMANDE_ID, $this->demande_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getDemandeId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setDemandeId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setDate($this->date);

		$copyObj->setNom($this->nom);

		$copyObj->setPrenom($this->prenom);

		$copyObj->setStatutId($this->statut_id);

		$copyObj->setStatutAutre($this->statut_autre);

		$copyObj->setEtablissementId($this->etablissement_id);

		$copyObj->setStructureAutre($this->structure_autre);

		$copyObj->setIntituleEtude($this->intitule_etude);

		$copyObj->setTypeDonneesId($this->type_donnees_id);

		$copyObj->setTypeDonneesAutre($this->type_donnees_autre);

		$copyObj->setPeriodeDebut($this->periode_debut);

		$copyObj->setPeriodeFin($this->periode_fin);

		$copyObj->setFormatDonneesId($this->format_donnees_id);

		$copyObj->setIsBesoinAssistance($this->is_besoin_assistance);

		$copyObj->setTypeMotivationId($this->type_motivation_id);

		$copyObj->setCommentaire($this->commentaire);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getDemandeEvaluations() as $relObj) {
				$copyObj->addDemandeEvaluation($relObj->copy($deepCopy));
			}

			foreach($this->getDemandeSupervisions() as $relObj) {
				$copyObj->addDemandeSupervision($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setDemandeId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new DemandePeer();
		}
		return self::$peer;
	}

	
	public function setTypeStatut($v)
	{


		if ($v === null) {
			$this->setStatutId(NULL);
		} else {
			$this->setStatutId($v->getIdstatut());
		}


		$this->aTypeStatut = $v;
	}


	
	public function getTypeStatut($con = null)
	{
		if ($this->aTypeStatut === null && ($this->statut_id !== null)) {
						$this->aTypeStatut = TypeStatutPeer::retrieveByPK($this->statut_id, $con);

			
		}
		return $this->aTypeStatut;
	}

	
	public function setEtablissement($v)
	{


		if ($v === null) {
			$this->setEtablissementId(NULL);
		} else {
			$this->setEtablissementId($v->getIdetablissement());
		}


		$this->aEtablissement = $v;
	}


	
	public function getEtablissement($con = null)
	{
		if ($this->aEtablissement === null && ($this->etablissement_id !== null)) {
						$this->aEtablissement = EtablissementPeer::retrieveByPK($this->etablissement_id, $con);

			
		}
		return $this->aEtablissement;
	}

	
	public function setTypeDonnees($v)
	{


		if ($v === null) {
			$this->setTypeDonneesId(NULL);
		} else {
			$this->setTypeDonneesId($v->getIdtypeDonnee());
		}


		$this->aTypeDonnees = $v;
	}


	
	public function getTypeDonnees($con = null)
	{
		if ($this->aTypeDonnees === null && ($this->type_donnees_id !== null)) {
						$this->aTypeDonnees = TypeDonneesPeer::retrieveByPK($this->type_donnees_id, $con);

			
		}
		return $this->aTypeDonnees;
	}

	
	public function setTypeFormatDonnees($v)
	{


		if ($v === null) {
			$this->setFormatDonneesId(NULL);
		} else {
			$this->setFormatDonneesId($v->getIdformatDonnees());
		}


		$this->aTypeFormatDonnees = $v;
	}


	
	public function getTypeFormatDonnees($con = null)
	{
		if ($this->aTypeFormatDonnees === null && ($this->format_donnees_id !== null)) {
						$this->aTypeFormatDonnees = TypeFormatDonneesPeer::retrieveByPK($this->format_donnees_id, $con);

			
		}
		return $this->aTypeFormatDonnees;
	}

	
	public function setTypeMotivation($v)
	{


		if ($v === null) {
			$this->setTypeMotivationId(NULL);
		} else {
			$this->setTypeMotivationId($v->getIdtypeMotivation());
		}


		$this->aTypeMotivation = $v;
	}


	
	public function getTypeMotivation($con = null)
	{
		if ($this->aTypeMotivation === null && ($this->type_motivation_id !== null)) {
						$this->aTypeMotivation = TypeMotivationPeer::retrieveByPK($this->type_motivation_id, $con);

			
		}
		return $this->aTypeMotivation;
	}

	
	public function initDemandeEvaluations()
	{
		if ($this->collDemandeEvaluations === null) {
			$this->collDemandeEvaluations = array();
		}
	}

	
	public function getDemandeEvaluations($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collDemandeEvaluations === null) {
			if ($this->isNew()) {
			   $this->collDemandeEvaluations = array();
			} else {

				$criteria->add(DemandeEvaluationPeer::DEMANDE_ID, $this->getDemandeId());

				DemandeEvaluationPeer::addSelectColumns($criteria);
				$this->collDemandeEvaluations = DemandeEvaluationPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(DemandeEvaluationPeer::DEMANDE_ID, $this->getDemandeId());

				DemandeEvaluationPeer::addSelectColumns($criteria);
				if (!isset($this->lastDemandeEvaluationCriteria) || !$this->lastDemandeEvaluationCriteria->equals($criteria)) {
					$this->collDemandeEvaluations = DemandeEvaluationPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastDemandeEvaluationCriteria = $criteria;
		return $this->collDemandeEvaluations;
	}

	
	public function countDemandeEvaluations($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(DemandeEvaluationPeer::DEMANDE_ID, $this->getDemandeId());

		return DemandeEvaluationPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addDemandeEvaluation(DemandeEvaluation $l)
	{
		$this->collDemandeEvaluations[] = $l;
		$l->setDemande($this);
	}

	
	public function initDemandeSupervisions()
	{
		if ($this->collDemandeSupervisions === null) {
			$this->collDemandeSupervisions = array();
		}
	}

	
	public function getDemandeSupervisions($criteria = null, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collDemandeSupervisions === null) {
			if ($this->isNew()) {
			   $this->collDemandeSupervisions = array();
			} else {

				$criteria->add(DemandeSupervisionPeer::DEMANDE_ID, $this->getDemandeId());

				DemandeSupervisionPeer::addSelectColumns($criteria);
				$this->collDemandeSupervisions = DemandeSupervisionPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(DemandeSupervisionPeer::DEMANDE_ID, $this->getDemandeId());

				DemandeSupervisionPeer::addSelectColumns($criteria);
				if (!isset($this->lastDemandeSupervisionCriteria) || !$this->lastDemandeSupervisionCriteria->equals($criteria)) {
					$this->collDemandeSupervisions = DemandeSupervisionPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastDemandeSupervisionCriteria = $criteria;
		return $this->collDemandeSupervisions;
	}

	
	public function countDemandeSupervisions($criteria = null, $distinct = false, $con = null)
	{
				if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(DemandeSupervisionPeer::DEMANDE_ID, $this->getDemandeId());

		return DemandeSupervisionPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addDemandeSupervision(DemandeSupervision $l)
	{
		$this->collDemandeSupervisions[] = $l;
		$l->setDemande($this);
	}

} 